%Image Processing Assignment - 2
%Name: - Kirtish Dhande
%Class: - B.E. - C
%Roll no: - 54
% This is the program for gray to color transformation of a grayscale image.
%Date of assignment - 19/01/2016

%Variables declared -
% A - used to access original image.
% R1 - used to work on resultant/final image.
% Z - has double presicion values of original image.
% R - will store all the red intensity values of color image.
% G - will store all the green intensity values of color image.
% B - will store all the blue intensity values of color image.

clc;
clear all;
close all;

%This stores the pixel values of images in A.
A = imread('cameraman.tif');

%Displays the image in A.
imshow(A)
title('Original Image');

%To flip the image we need the size of the image first.
[m,n]= size(A);

%Convert and store values as double in A.
Z = double(A);

R = zeros(m,n);
G = zeros(m,n);
B = zeros(m,n);

%Here we are putting up colors to a grayscale image by multipying a
%constant of each Red, Green and Blue color to the pixels' intensity.
for i = 1 : m
    for j = 1 : n
        R(i,j) = 0.11*Z(i,j);
        G(i,j) = 0.33*Z(i,j);
        B(i,j) = Z(i,j);
    end
end    

% We store the resultant color intensity values in resultant array.
    R1(:,:,1) = R;
    R1(:,:,2) = G;
    R1(:,:,3) = B;

%Displays the image in A1 as well as previous image A.
figure, imshow(uint8(R1));
title('Image at night');
    